home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / VGAZOOM.ASM < prev    next >
Assembly Source File  |  1989-02-22  |  15KB  |  782 lines

  1. page ,132
  2.  
  3. ;--------------------------------------------------------------------------
  4. ; Filename:     VGAZOOM1.ASM
  5. ; Program name:    VGAZOOM.COM
  6. ;
  7. ; Link with:    VGAZOOM2.OBJ (Hidden mode driver module)
  8. ;
  9. ; Description:    This program demonstrates hidden VGA modes. The program
  10. ;        is a Terminate-And-Stay-Resident module that provides
  11. ;        elementary Video BIOS support for the hidden modes.
  12. ;        Applications that only use MS-DOS function 09h (print 
  13. ;        string) for video output, should work with this program. 
  14. ;
  15. ;        The program traps the Int 10h vector to provide extended
  16. ;        BIOS support. The program also traps int 9h (keyboard), 
  17. ;        to handle detection of Hotkeys for panning and mode 
  18. ;        switching etc.
  19. ;
  20. ; Version:    1.0
  21. ; Date:        June 8, 1988
  22. ;
  23. ; (c) Arun Johary, Bo Ericsson 1988
  24. ;--------------------------------------------------------------------------
  25.  
  26.  
  27. ;------    equates -------------------------------------------------------
  28. TRUE        equ    1
  29. FALSE        equ    0
  30. CR        equ    0dh
  31. LF        equ    0ah
  32. BS        equ    08h
  33. EOS        equ    '$'
  34. ACTIVE        equ    TRUE
  35. INACTIVE    equ    FALSE
  36. LORES        equ    0
  37. HIRES        equ    1
  38. HIDDENMODE    equ    21h
  39.  
  40. CTRLMAKE        equ    01dh
  41. CTRLBREAK        equ    09dh
  42. SETLORES        equ    1
  43. SETLORESMAKE        equ    050h
  44. SETLORESBREAK        equ    0d0h
  45. SETHIRES        equ    2
  46. SETHIRESMAKE        equ    048h
  47. SETHIRESBREAK        equ    0c8h
  48. PANRIGHTONE        equ    3
  49. PANRIGHTONEMAKE        equ    04dh
  50. PANRIGHTONEBREAK    equ    0cdh
  51. PANLEFTONE        equ    4
  52. PANLEFTONEMAKE        equ    04bh
  53. PANLEFTONEBREAK        equ    0cbh
  54.  
  55.  
  56. ;------ externals -----------------------------------------------------
  57. extrn    SetMode:near
  58. extrn    DrawChr:near
  59. extrn    Horiz_Scroll_4:near
  60. extrn    EndOfProgram:byte
  61.  
  62.  
  63. ;------    macros --------------------------------------------------------
  64. pushall    macro
  65.     push    ax
  66.     push    bx
  67.     push    cx
  68.     push    dx
  69.     push    di
  70.     push    si
  71.     push    ds
  72.     push    es
  73.     push    bp
  74.     endm
  75.  
  76. popall    macro
  77.     pop    bp
  78.     pop    es
  79.     pop    ds
  80.     pop    si
  81.     pop    di
  82.     pop    dx
  83.     pop    cx
  84.     pop    bx
  85.     pop    ax
  86.     endm
  87.  
  88.  
  89. ;------    structures ----------------------------------------------------
  90.  
  91.  
  92. ;------ code segment --------------------------------------------------
  93. code segment para public 'code'
  94.     assume cs:code, ds:code, es:code, ss:code
  95.     org    100h
  96. begin:
  97.     jmp    Main
  98.  
  99.  
  100. ;------ data area -----------------------------------------------------
  101. Msg0    db    'VGAZOOM.COM - VGA hidden mode driver - Ver. 1.0', CR, LF
  102.     db    '  Program by Arun Johary and Bo Ericsson', CR, LF, LF, EOS  
  103. Msg1    db    'Program installed', CR, LF, EOS
  104. Msg2    db    'New program did not install', CR, LF, EOS
  105. Msg3    db    'Program already installed', CR, LF, EOS
  106. Msg4    db    'VGA not present. Program did not install', CR, LF, EOS
  107.  
  108. Msg5    db    'To set High resolution (1280x400), press Ctrl Up-Arrow', CR, LF
  109.     db    'To set Low resolution, (640x400) press Ctrl Down-Arrow', CR, LF
  110.     db    'To Pan right in Low resolution, press Ctrl Right-Arrow', CR, LF
  111.     db    'To Pan left in Low resolution, press Ctrl Left-Arrow', CR, LF, LF, EOS
  112.  
  113. Command        db    0
  114. Status        db    HIRES
  115. VideoMode    db    0
  116.  
  117. CtrlStatus        db    FALSE
  118. LoResStatus        db    FALSE
  119. HiResStatus        db    FALSE
  120. PanRightOneStatus    db    FALSE
  121. PanLeftOneStatus    db    FALSE
  122. PanPosition        dw    0
  123.  
  124. ScanCode    db    0
  125.  
  126. MemOffset    dw    00000h
  127. MemSegment    dw    0a000h
  128. FontOffset    dw    0
  129. FontSegment    dw    0
  130.  
  131.  
  132. ;-----------------------------------------------------------------------
  133. Main proc near
  134.  
  135. ;------ are we already installed?
  136.     call    CheckAlreadyInstalled
  137.     jc    MainError
  138.  
  139. ;------ is this a VGA environment?
  140.     mov    ax, 1a00h
  141.     int    10h
  142.     cmp    al, 1ah
  143.     jne    NotVGA
  144.  
  145.     call    SetNewVideoVector
  146.      call    SetNewKeyboardVector
  147.  
  148. ;------ display initial greeting
  149.     mov    ax, HIDDENMODE
  150.     int    10h
  151.     mov    dx, offset Msg0
  152.     mov    ah, 9
  153.     int    21h
  154.     mov    dx, offset Msg1
  155.     mov    ah, 9
  156.     int    21h
  157.     mov    dx, offset Msg5
  158.     mov    ah, 9
  159.     int    21h
  160.  
  161.     call    TerminateButStayResident
  162.  
  163. ;------ TSR failed
  164. MainError:
  165.     mov    ax, HIDDENMODE
  166.     int    10h
  167.     mov    dx, offset Msg0
  168.     mov    ah, 9
  169.     int    21h
  170.     mov    dx, offset Msg3
  171.     mov    ah, 9
  172.     int    21h
  173.     mov    dx, offset Msg2
  174.     mov    ah, 9
  175.     int    21h
  176.     mov    dx, offset Msg5
  177.     mov    ah, 9
  178.     int    21h
  179.     ret
  180.  
  181. ;------ VGA environment not found
  182. NotVGA:
  183.     mov    dx, offset Msg0
  184.     mov    ah, 9
  185.     int    21h
  186.     mov    dx, offset Msg4
  187.     mov    ah, 9
  188.     int    21h
  189.     ret
  190.     
  191.  
  192. Main endp
  193.  
  194.  
  195. ;-----------------------------------------------------------------------
  196. CheckAlreadyInstalled proc near
  197.  
  198. ;------ get video interrupt vector
  199.     mov    ah, 35h            ;get interrupt vector function
  200.     mov    al, 10h            ;vector number
  201.     int    21h            ;execute! (returns es:bx)
  202.     
  203. ;------ look for already-present marker
  204.     cld                ;forward direction
  205.     mov    di, bx
  206.     add    di, Marker-VideoHandler    ;offset to marker string
  207.     mov    si, offset Marker    ;offset to our string
  208.     mov    cx, MarkerEnd-Marker    ;length of string
  209.     repe    cmpsb            ;compare the strings
  210.     jcxz    AlreadyLoaded        ;compare ok, handler already loaded
  211.     jmp    NotAlreadyLoaded    ;compare not ok, handler not there
  212.  
  213. ;------ Program already loaded
  214. AlreadyLoaded:
  215.     stc                ;error= set carry flag
  216.     ret
  217.  
  218. ;------ New installation
  219. NotAlreadyLoaded:
  220.     clc                ;success= cleared carry flag  
  221.     ret
  222.     
  223. CheckAlreadyInstalled endp
  224.  
  225.  
  226. ;-----------------------------------------------------------------------
  227. SetNewVideoVector proc near
  228.  
  229. ;------ get old video interrupt vector
  230.     mov    ah, 35h            ;get interrupt vector function
  231.     mov    al, 10h            ;video vector 
  232.     int    21h            ;execute! (returns es:bx)
  233.  
  234. ;------ and store it
  235.     mov    cs:OldVideoOffs0, bx    ;store offset of old handler
  236.     mov    cs:OldVideoOffs1, bx    ;store offset of old handler
  237.     mov    ax, es
  238.     mov    cs:OldVideoSeg0, ax    ;store segment of old handler
  239.     mov    cs:OldVideoSeg1, ax    ;store segment of old handler
  240.  
  241. ;------ link our handler into the chain 
  242.     mov    ah, 25h            ;set interrupt vector function
  243.     mov    al, 10h            ;interrupt number
  244.     mov    dx, offset VideoHandler ;ds:dx= address to handler
  245.     int    21h            ;execute!
  246.  
  247. ;------ locate 8*8 font in ROM
  248.     mov    ah, 11h
  249.     mov    al, 30h
  250.     mov    bh, 03h
  251.     int    10h
  252.     mov    cs:FontSegment, es
  253.     mov    cs:FontOffset, bp
  254.     ret
  255.  
  256. SetNewVideoVector endp
  257.  
  258.  
  259. ;-----------------------------------------------------------------------
  260. SetNewKeyboardVector proc near
  261.  
  262. ;------ get keyboard interupt vector
  263.     mov    ah, 35h            ; get vector function call
  264.     mov     al, 9h            ; int 9h vector
  265.     int     21h            ; dos call
  266.     mov    ax, es            ; es contains cs
  267.     mov    cs:OldKeyboardSegment, ax ; save cs
  268.     mov    cs:OldKeyboardOffset, bx ; save ip
  269.  
  270. ;------ set new keyboard interupt vector
  271.     push    cs
  272.     pop    ds
  273.     mov    dx,offset KeyboardHandler ; specify offset to keyboard int trap
  274.     mov     ah, 25h            ; set vector function call
  275.     mov    al, 9h            ; int 9h vector
  276.      int     21h            ; dos call
  277.  
  278.     ret
  279.  
  280. SetNewKeyboardVector endp
  281.  
  282.  
  283. ;-----------------------------------------------------------------------
  284. TerminateButStayResident proc near
  285.  
  286.     mov    dx, offset EndOfProgram    ;divide offset of end of program
  287.     mov    cl, 4
  288.     shr    dx, cl            ;by four
  289.     inc    dx            ;and increment result by 1
  290.  
  291.     mov    ah, 31h            ;terminate but stay resident func
  292.     mov    al, 0            ;return code
  293.     int    21h            ;execute
  294.  
  295.     stc                ;could not TSR the program
  296.     ret
  297.  
  298. TerminateButStayResident endp
  299.  
  300.  
  301. ;-----------------------------------------------------------------------
  302. VideoHandler proc far
  303.  
  304. ;------ trap entry to old video handler
  305.     call    PreBios
  306.  
  307. ;------ call old video handler
  308.         pushf
  309. LongCall0    db    09ah        
  310. OldVideoOffs0    dw    0
  311. OldVideoSeg0    dw    0
  312.  
  313. ;------ trap exit from old video handler
  314.     call    PostBios
  315.  
  316. ;------ return to application
  317.     iret
  318.  
  319. Marker        db    'Hidden VGA mode program'
  320. MarkerEnd    label     byte
  321.  
  322. VideoHandler endp
  323.  
  324.  
  325. ;-----------------------------------------------------------------------
  326. PreBios proc near
  327.  
  328.     cmp    ah, 0
  329.     je    PreBiosModeSet
  330.     cmp    ah, 0eh
  331.     je    PreBiosTTYOutput
  332.     cmp    ah, 6
  333.     je    PreBiosScroll
  334.     ret
  335.  
  336. PreBiosModeSet:
  337.     call    HandlePreModeSet
  338.     ret
  339.  
  340. PreBiosTTYOutput:
  341.     call    HandlePreTTYOutput
  342.     ret
  343.  
  344. PreBiosScroll:
  345.     call    HandlePreScroll
  346.     ret
  347.  
  348. PreBios endp
  349.  
  350.  
  351. ;-----------------------------------------------------------------------
  352. HandlePreModeSet proc near
  353.  
  354.     mov    cs:VideoMode, al
  355.     cmp    al, HIDDENMODE
  356.     je    SetHiddenMode
  357.     ret
  358.  
  359. SetHiddenMode:
  360.     pushall
  361.  
  362.     mov    ax, 0eh
  363.         pushf
  364. LongCall1    db    09ah        
  365. OldVideoOffs1    dw    0
  366. OldVideoSeg1    dw    0
  367.  
  368. ;set the hidden mode here
  369.  
  370.     mov    ax, HIRES
  371.     call    SetMode
  372.     mov    cs:Status, HIRES
  373.     mov    ax, 40h
  374.     mov    ds, ax
  375.     mov    bx, 4ah
  376.     mov    [bx], byte